﻿using Basic.HrGatewayModular.Interface;
using Basic.HrGatewayModular.Model.EmpLogin;
using WeDonekRpc.ApiGateway.Attr;
using WeDonekRpc.Helper.Validate;
using WeDonekRpc.HttpApiGateway;
using WeDonekRpc.HttpApiGateway.Interface;

namespace Basic.HrGatewayModular.Api
{
    [ApiRouteName("/hr/emplogin/{name}")]
    internal class LoginApi : ApiController
    {
        private readonly ILoginService _Service;

        public LoginApi ( ILoginService service )
        {
            this._Service = service;
        }
        /// <summary>
        /// 人员密码登陆
        /// </summary>
        /// <param name="param">参数</param>
        /// <returns>登陆结果</returns>
        [ApiPower(false)]
        public EmpLoginRes EmpPwdLogin ( [NullValidate("hr.emplogin.param.null")] UI_EmpPwdLogin param )
        {
            return this._Service.EmpPwdLogin(param, this.Request.ToLoginState());
        }
        [ApiPower(false)]
        public bool CheckIsVerCode ( [NullValidate("hr.login.name.null")][LenValidate("hr.login.name.len", 6, 20)] string name )
        {
            return this._Service.CheckIsVerCode(name);
        }
        [ApiPower(false)]
        public IResponse CreateCode ( [NullValidate("hr.login.name.null")][LenValidate("hr.login.name.len", 6, 20)] string name )
        {
            return this._Service.CreateCode(name);
        }
    }
}
